package com.logistics.inventory.entity.model;

import com.logistics.material.entity.model.MaterialPickSave;
import com.logistics.utils.bean.SaveBasic;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class InventoryDetailSave extends SaveBasic {

    private String id;
    // 托盘号
    private String container;
    //
    private Integer itemSeqNo;
    // 物料编号
    private String itemCode;
    // 物料任务号
    private String itemWorkCode;
    // 物料工序号
    private String itemOpNo;
    // 物料名
    private String itemName;
    // 物料单位
    private String itemUnit;
    // 物料数量
    private BigDecimal itemQty;

    public static InventoryDetailSave build(MaterialPickSave save){
        InventoryDetailSave inventoryDetailSave = new InventoryDetailSave();
        inventoryDetailSave.setContainer(save.getContainerCode());
        inventoryDetailSave.setItemCode(save.getItemCode());
        inventoryDetailSave.setItemWorkCode(save.getTaskNo());
        inventoryDetailSave.setItemOpNo(save.getItemOpNo());
        inventoryDetailSave.setItemName(save.getItemName());
        inventoryDetailSave.setItemUnit(save.getItemUnit());
        inventoryDetailSave.setItemSeqNo(StringUtils.isNotNull(save.getItemSeqNo()) ? Integer.parseInt(save.getItemSeqNo()) : null);
        inventoryDetailSave.setItemQty(StringUtils.isNotNull(save.getItemQty()) ? new BigDecimal(save.getItemQty()) : BigDecimal.ZERO);
        inventoryDetailSave.setCreateDepCode(save.getCreateDepCode());
        inventoryDetailSave.setCreator(save.getCreator());
        inventoryDetailSave.setCreateOrgCode(save.getCreateOrgCode());
        inventoryDetailSave.setCreateTime(save.getCreateTime());
        inventoryDetailSave.setUpdater(save.getUpdater());
        inventoryDetailSave.setUpdateTime(save.getUpdateTime());
        return inventoryDetailSave;
    }
}
